<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>DojoAjax</title>
<script type="text/javascript">
	var djConfig = {isDebug:true, parseOnLoad:true };
</script>
<script type="text/javascript" src="dojo/dojo-release-1.2.0/dojo/dojo.js"></script>
<script type="text/javascript">
	function successResponse(response){
		document.getElementById('response').innerHTML = response;
		return response;
	}

	function errorHandler(response, ioArgs) { 
		console.error("HTTP status code: ", ioArgs.xhr.status); 
		console.error("Error Msg: ", ioArgs.xhr.getResponseHeader('errorMsg'));
		document.getElementById('response').innerHTML = '<font color="red">Response: '+response+
		'<br/>Error Message: '+ioArgs.xhr.getResponseHeader('errorMsg')+'</font>';
		return response; 
	}
    	
	function postToServlet(){
		console.debug('about to post form data to servlet');
		dojo.xhrPost({
			url: '/employeeServlet',
			handleAs: 'text',
			load: successResponse,
        	form: "post-form",
        	error: errorHandler
        	});
		console.debug('after posting form data to servlet');
      }
      
    </script>

</head>
<body>
	<div id='response'></div>
	<div>
		<form id='post-form' method="POST">
			<input type='text' name='name' ID="one-test" />
			<input id="next" type="button" onclick="postToServlet();" value="Next" />
		</form>
	</div>
</body>
</html>